package com.zoe.onelink.core.web.response.trace;

import brave.Tracer;
import lombok.RequiredArgsConstructor;

/**
 * <p>标题: </p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2021</p>
 * <p>公司: 智业软件股份有限公司</p>
 *
 * @version: 1.0
 * @author: ruansheng
 * @date: 2021-12-09
 */
@RequiredArgsConstructor
public class ZipkinTraceIdProvider implements TraceIdProvider {

    private final Tracer tracer;

    @Override
    public String getTraceId() {
        if (this.tracer == null) {
            return null;
        }
        return this.tracer.currentSpan().context().traceIdString();
    }
}
